<template>
	<view class="mainpadding2">
		
		<view class="ffffff mainpadding_top flexbetween radius">
			<view class="hei_text bold titletext">名稱</view>
			<input type="text" class="hei_text main_size bold" style="text-align: right;" placeholder="請輸入名稱" v-model="name">
		</view>
		<view class="ffffff mainpadding_top radius">
			<view class="hei_text bold titletext">内容</view>
			<textarea placeholder="請輸入内容" maxlength="-1" class="margin-top" v-model="des" style="width: 100%;height: 150rpx;"></textarea>
		</view>
		 <timePicker :messageTime="messageTime" @timeConfirm="timeConfirm"></timePicker>
		<view class="submitbtn margin_top" @click="submit">確認</view>
	</view>
</template>

<script>
	const httpRequest = require("@/common/httpRequest.js")
	export default {
		data() {
			return {
				name:"",
				des:"",
				issubmit:false
			}
		},
		onLoad(options) {
			if(options.id){
				this.listid = options.id
				uni.setNavigationBarTitle({
					title:"編輯出货须知"
				})
				this.getDetail()
			}
		},
		methods: {
			getDetail(){
				this.http.request("/api/goods/goodsXzDetail", 'GET', {
					id:this.listid
				}).then(res=>{
					let data = res.data
					this.name=data.name
					this.des=data.des
				})
			},
			async submit(){
				if(this.name==""){
					this.http.toast("請輸入名稱")
					return false
				}
				if(this.des==""){
					this.http.toast("請輸入内容")
					return false
				}
				if(this.issubmit) return
				this.issubmit = true
				let datamsg = {
					shop_id:uni.getStorageSync("shop_id"),
					name:this.name,
					des:this.des,
					type:1,
				}
				let url = "/api/goods/addGoodsXz"
				if(this.listid){
					url = "/api/goods/editGoodsXz"
					delete datamsg.type
					this.$set(datamsg,"id",this.listid)
				}
				uni.showLoading({
					mask:true,
					title:"請稍後"
				})
				let res = await this.http.request(url, 'GET', datamsg)
				uni.hideLoading()
				if(res.code==1){
					this.http.toast(res.msg)
					setTimeout(()=>{
						uni.navigateBack(1)
					},1000)
				}else{
					this.issubmit = false
					this.http.toast(res.msg)
				}
			},
		}
	}
</script>

<style lang="scss" scoped>
::v-deep.u-radio-group {
		flex: none !important;
	}
</style>